class Admin::MailSettingsController < Admin::BaseController
      before_filter :is_administrator
  # GET /mail_settings
  # GET /mail_settings.xml
  def index
    @mail_settings = MailSetting.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @mail_settings }
    end
  end

  # GET /mail_settings/1
  # GET /mail_settings/1.xml
  def show
    @mail_setting = MailSetting.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @mail_setting }
    end
  end

  # GET /mail_settings/new
  # GET /mail_settings/new.xml
  def new
    @mail_setting = MailSetting.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @mail_setting }
    end
  end

  # GET /mail_settings/1/edit
  def edit
    @mail_setting = MailSetting.find(params[:id])
  end

  # POST /mail_settings
  # POST /mail_settings.xml
  def create
    @mail_setting = MailSetting.new(params[:mail_setting])

    respond_to do |format|
      if @mail_setting.save
        flash[:notice] = 'MailSetting was successfully created.'
        format.html { redirect_to admin_mail_settings_path }
        format.xml  { render :xml => @mail_setting, :status => :created, :location => @mail_setting }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @mail_setting.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /mail_settings/1
  # PUT /mail_settings/1.xml
  def update
    @mail_setting = MailSetting.find(params[:id])

    respond_to do |format|
      if @mail_setting.update_attributes(params[:mail_setting])
        flash[:notice] = 'MailSetting was successfully updated.'
        format.html { redirect_to(admin_mail_settings_path) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @mail_setting.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /mail_settings/1
  # DELETE /mail_settings/1.xml
  def destroy
    @mail_setting = MailSetting.find(params[:id])
    @mail_setting.destroy

    respond_to do |format|
      format.html { redirect_to(admin_mail_settings_path) }
      format.xml  { head :ok }
    end
  end
  def setmail
    @mail_settings = MailSetting.find(:all)
    @mail_settings.each do |mail|
      mail.update_attribute(:status ,false)
    end
    @mail_setting = MailSetting.find(params[:id])
    @mail_setting.update_attribute(:status ,true)
    redirect_to(admin_mail_settings_path)
  end
end
